<template>
  <div class="add-pople">
    <!-- 表单组件 -->
    <formCom :formListIndex="formListIndex"></formCom>
    <div style="width: 100%;height:7rem;"></div>
    <div class="submit-form-box">
      <div @click="$router.go(-1)" class="submit-form">
        保存
      </div>
    </div>
  </div>
</template>
<script>
import formCom from "./formCom"; //表单组件
export default {
  components: {
    formCom
  },
  data() {
    return {
      formListIndex: 0
    };
  },
  created() {
    // 如果没有报名字段则返回重新获取
    if (this.$store.state.formFiled.componenList.length == 0) {
      this.$Toast({
        message: "报名表单数据获取失败，将重新获取",
        position: "middle",
        duration: 3000
      });
      this.$router.push({
        name: "login"
      });
    }
    this.$store.state.thisEditTemplateId =
      this.$route.params.templateId || this.$store.state.thisEditTemplateId; //确定当前编辑的模板id(go(-1)会出现路由没有值的情况)
    //根据模板id确定当前编辑的json
    for (let i = 0; i < this.$store.state.formList.length; i++) {
      if (
        this.$store.state.formList[i].templateId ==
        this.$store.state.thisEditTemplateId
      ) {
        this.formListIndex = i;
      }
    }
  }
};
</script>

<style scoped>
.add-pople {
  width: 100%;
  height: 100%;
  background: #f4f5f4;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.submit-form-box {
  position: fixed;
  bottom: 0rem;
  left: 0rem;
  width: 100%;
  height: 5rem;
  z-index: 99;
  background: #ffffff;
  border-top: 0.1rem solid #dedede;
  display: flex;
  -webkit-display: flex;
  -webkit-justify-content: center;
  justify-content: center;
  -webkit-align-items: center;
  align-items: center;
}
.submit-form {
  background: #ff3e85;
  font-size: 1.4rem;
  color: #ffffff;
  width: 69%;
  height: 3.5rem;
  line-height: 3.5rem;
  cursor: pointer;
}
</style>
